package com.ruoyi.ybUpload.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ybUpload.domain.tableCode.InterfaceRecords;
import com.ruoyi.ybUpload.service.tableCode.IInterfaceRecordsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 接口请求接收参数记录Controller
 *
 * @author ruoyi
 * @date 2024-08-22
 */
@RestController
@RequestMapping("/ybUpload/interfaceRecords")
public class InterfaceRecordsController extends BaseController
{
    @Autowired
    private IInterfaceRecordsService interfaceRecordsService;

    /**
     * 查询接口请求接收参数记录列表
     */
    @PreAuthorize("@ss.hasPermi('ybUpload:records:list')")
    @GetMapping("/list")
    public TableDataInfo list(InterfaceRecords interfaceRecords)
    {
        startPage();
        List<InterfaceRecords> list = interfaceRecordsService.selectInterfaceRecordsList(interfaceRecords);
        return getDataTable(list);
    }

    /**
     * 导出接口请求接收参数记录列表
     */
    @PreAuthorize("@ss.hasPermi('ybUpload:records:export')")
    @Log(title = "接口请求接收参数记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InterfaceRecords interfaceRecords)
    {
        List<InterfaceRecords> list = interfaceRecordsService.selectInterfaceRecordsList(interfaceRecords);
        ExcelUtil<InterfaceRecords> util = new ExcelUtil<InterfaceRecords>(InterfaceRecords.class);
        util.exportExcel(response, list, "接口请求接收参数记录数据");
    }

    /**
     * 获取接口请求接收参数记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('ybUpload:records:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(interfaceRecordsService.selectInterfaceRecordsById(id));
    }

    /**
     * 新增接口请求接收参数记录
     */
    @PreAuthorize("@ss.hasPermi('ybUpload:records:add')")
    @Log(title = "接口请求接收参数记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InterfaceRecords interfaceRecords)
    {
        return toAjax(interfaceRecordsService.insertInterfaceRecords(interfaceRecords));
    }

    /**
     * 修改接口请求接收参数记录
     */
    @PreAuthorize("@ss.hasPermi('ybUpload:records:edit')")
    @Log(title = "接口请求接收参数记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InterfaceRecords interfaceRecords)
    {
        return toAjax(interfaceRecordsService.updateInterfaceRecords(interfaceRecords));
    }

    /**
     * 删除接口请求接收参数记录
     */
    @PreAuthorize("@ss.hasPermi('ybUpload:records:remove')")
    @Log(title = "接口请求接收参数记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(interfaceRecordsService.deleteInterfaceRecordsByIds(ids));
    }
}